package peer.util;

import java.util.ArrayList;

import model.dto.BlockDTO;
import model.enums.BlockStatus;
import peer.model.consts.TransferConsts;


public class TransferUtil {

	public static Integer partition(long transferSize){
		return (int) (transferSize / TransferConsts.TRANSFER_BUFFER_SIZE);
	}


	public int getFileBlockCount(long size){
		return (int) (size/TransferConsts.TRANSFER_BUFFER_SIZE);
	}

	public ArrayList<BlockDTO> getBlocksArray(int size){
		ArrayList<BlockDTO> list=new ArrayList<BlockDTO>();
		int blocks=this.getFileBlockCount(size);
		for(int a=0;a<blocks;a++){
			list.add(new BlockDTO(a*TransferConsts.TRANSFER_BUFFER_SIZE, null, BlockStatus.WAITING));
		}
		return list;
	}

}
